package com.lagou.edu.controller;

import com.lagou.edu.service.UserService;
import com.lagou.edu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author grung
 * @Date 2020/10/23 13:30
 * @Version 1.0
 */

@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/login/{email}/{password}")
    public Result login(@PathVariable("email") String email,
                        @PathVariable("password") String password,
                        HttpServletRequest request, HttpServletResponse response) {


        return userService.login(email, password, response);

    }


    @GetMapping("/register/{email}/{password}/{code}")
    public Result register(@PathVariable("email") String email,
                           @PathVariable("password") String password,
                           @PathVariable("code") String code,
                           HttpServletResponse response) {


        return userService.register(email, password, code, response);

    }

    @GetMapping("/info/{token}")
    public Result info(@PathVariable("token") String token) {


        return userService.info(token);

    }


}
